<%@page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@taglib uri="TowkerTagLib" prefix="rbac"%>
<%@include file="/commons/include/html_doctype.html"%>
<html>
<head>
	<title>修改</title>
	<%@include file="/commons/include/upd.jsp" %>
	<link rel="stylesheet" href="${ctx}/js/jquery/ui/css/jquery-ui.css" />
    <script src="${ctx}/js/jquery/ui/jquery-ui.js"></script>
    <script src="${ctx}/js/jquery/ui/jquery.ui.combobox.js"></script>
	<script type="text/javascript">
$(function(){
	
	jQuery("#dataForm").validate(
	{
		rules: {
			dep_code:{
				required:true
			},
			dep_name:{
				required:true
			},
			co_code:{
				required:true
			}
		},
		messages: {
			dep_code:{
				required:"请填写部门代码"
			},
			dep_name:{
				required:"请填写部门名称"
			},
			co_code:{
				required:"请选择所属公司代码"
			}
		},
		submitHandler:function(form)
		{
			if($("#co_code").val() == "")
				$("#co_code").val($('#a_co_code').val());
			jQuery.ajax({
				url : ctx + '/manage/basicData/checkExistsDepCode.htm',
				type : "POST",
				data : {id:$('#deptId').val(),dep_code:$('#dep_code').val()},
				dataType : "json",
				success : function(d) {
				if(!d.result)
					jQuery(form).ajaxSubmit(_options);
				else
					alert('部门代码有重复!');
				},error:function(){
				   alert('后台验证部门代码出错');
				}
			});	
		}
	});
	
	if($("#co_code").val() != "") {
		$("#a_co_code").hide();
		$("#s_co_code").show();
	} else {
		$("#a_co_code").combobox();
		$("#s_co_code").hide();
	}
});
_callback = function() {
	location.href = ctx + "/manage/basicData/getDepartments.htm";
}
validCallBack = function()
{
	//添加页面自定义校验

	return true;
};
	</script>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0" class="listLogo">
	<tr>
		<td class="title">部门信息修改</td>
		<td>
			<div class="menuTool">
				<a class="save" id="dataFormSave" href="#">保存</a>
				<a class="back" href="getDepartments.htm">返回</a>
			</div>
		</td>
	</tr>
</table>
<div class="line"></div>
<form id="dataForm" method="post" action="updDepartments2.htm">
<table border="0" cellspacing="1" cellpadding="0" class="listTable">
	<tr>
		<td class="form_title">部门代码：</td>
		<td class="form_input"><input type="text" id="dep_code" name="dep_code" value="${fn:escapeXml(po.dep_code)}" /></td>
		
		<td class="form_title">部门名称：</td>
		<td class="form_input"><input type="text" id="dep_name" name="dep_name" value="${fn:escapeXml(po.dep_name)}" /></td>
		
		<td class="form_title">所属公司代码：</td>
		<td class="form_input">
		<select id="a_co_code" name="a_co_code">
				 <c:forEach items="${companiesList}" var="d" varStatus="status">
					<option value="${d.co_code}" <c:if test="${d.co_code==po.co_code}">selected="selected"</c:if> >${d.co_name}[${d.co_code}]</option>
				</c:forEach>
		</select>
        <span id="s_co_code">${co_code}</span>
		</td>
	</tr>
</table>
<input type="hidden" name="id" id="deptId" value="${po.id}" />
<input type="hidden" name="co_code" id="co_code" value="${co_code}" />
</form>
</body>
</html>
